﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Web/Master/BackMasterPage.master" AutoEventWireup="true" CodeFile="OrderManage.aspx.cs" Inherits="Web_Back_OrderManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <form id="formOrderList" runat="server">

        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
            <h1 class="h2">订单管理</h1>
            <div class="btn-toolbar mb-2 mb-md-0">
                <div class="btn-group me-2">
                    <asp:TextBox Style="display: none;" ID="OrderSate" runat="server"></asp:TextBox>
                    <asp:TextBox Style="display: none;" ID="NewState" runat="server"></asp:TextBox>
                    <asp:TextBox Style="display: none;" ID="OrderId" runat="server"></asp:TextBox>
                    <asp:Button class="btn btn-sm btn-outline-secondary"  ID="BtnUpdate" runat="server" Text="更新订单" Style="display: none;"  OnClick="BtnUpdate_Click" />
                    <asp:Button class="btn btn-sm btn-outline-secondary" ID="ButtonUnpaid" runat="server" Text="未付款" OnClick="ButtonUnpaid_Click" />
                    <asp:Button class="btn btn-sm btn-outline-secondary" ID="ButtonDelivered" runat="server" Text="待发货" OnClick="ButtonDelivered_Click" />
                    <asp:Button class="btn btn-sm btn-outline-secondary" ID="ButtonWaitReceive" runat="server" Text="待收货" OnClick="ButtonWaitReceive_Click" />
                    <asp:Button class="btn btn-sm btn-outline-secondary" ID="ButtonFinished" runat="server" Text="已完成" OnClick="ButtonFinished_Click" />
                    <%--<button type="button" class="btn btn-sm btn-outline-secondary">未付款</button>
            <button type="button" class="btn btn-sm btn-outline-secondary">待发货</button>
               <button type="button" class="btn btn-sm btn-outline-secondary">待收货</button>
            <button type="button" class="btn btn-sm btn-outline-secondary">已完成</button>--%>
                </div>
                <%--<button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
            <span data-feather="calendar"></span>
            This week
          </button>--%>
            </div>
        </div>


        <div id="page-wrapper">
            <!-- /.row -->
            <div class="panel panel-default">
                <!-- /.panel-heading -->
                <div class="panel-body">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>订单号</th>
                                <th>客户名</th>
                                <th>图书名称</th>
                                <th>图书封面</th>
                                <th>下单日期</th>
                                <th>数量</th>
                                <th>金额</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <%=OrderDetailList %>
                        </tbody>
                    </table>
                </div>
                <!-- /.panel-body -->
            </div>
            <!-- /.row -->
        </div>

        <!-- /#wrapper -->
        <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="text-danger">您确定要删除这条记录吗？</h3>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <asp:Button class="btn btn-danger btn-ok" ID="BtnDeleteOrder" runat="server" Text="删除" OnClick="BtnDeleteOrder_Click" />
                    </div>
                </div>
            </div>
        </div>



        <script>

            $(function () {

                var index = $(<%=OrderSate.ClientID%>).val();
                if (index >= 0) {
                $(".btn-group").find(".btn-outline-secondary").eq(index).addClass("active")
                }

                $("select").each(function () {
                    var state = $(this).parent().attr("state");
                    //alert(state)
                    $(this).children().eq(state-1).attr("selected", "selected");
                });

                $(".btn_delete").click(function () {
                    console.log($(this).parent().attr("orderId"));
                    $(<%=OrderId.ClientID%>).val($(this).parent().attr("orderId"));
                });

                $(".btn_update").click(function () {
                    var newstate = $("select").val();
                    $(<%=NewState.ClientID%>).val(newstate);
                    //alert(newstate);
                    var id = $(this).parent().attr("orderId");
                    $(<%=OrderId.ClientID%>).val(id);
                    
                    //alert($(<%=NewState.ClientID%>).val());
                    //alert($(<%=OrderId.ClientID%>).val());
                    $(<%=BtnUpdate.ClientID%>).click();
                });
            });
    </script>
    </form>

</asp:Content>

